TARGETS = atomictest app_unsafe app_safe_fence app_thread_and_signal \
	app_memory_barrier app_seqno app_memory_barrier_asm_v1 app_memory_barrier_asm_v2 \
	app_memory_barrier_asm_v3 app_memory_barrier_asm_v4 app_memory_barrier_asm_v5 app_atomic

CPPFLAGS = -std=c++11 -g -O2
LIBS = -lpthread

all: $(TARGETS)


%.o : %.cpp
	g++ $(CPPFLAGS) -c $< -o $@

atomictest: atomic_main.o
	g++ $^ -o atomictest $(LIBS)

app_unsafe: app_unsafe.o
	g++ $^ -o app_unsafe $(LIBS)

app_safe_fence: app_safe_fence.o
	g++ $^ -o app_safe_fence $(LIBS)

app_thread_and_signal: app_thread_and_signal.o
	g++ $^ -o app_thread_and_signal $(LIBS)

app_memory_barrier: app_memory_barrier.o
	g++ $^ -o app_memory_barrier $(LIBS)

app_seqno: app_seqno.o
	g++ $^ -o app_seqno $(LIBS)

app_memory_barrier_asm_v1: app_memory_barrier_asm_v1.o
	g++ $^ -o app_memory_barrier_asm_v1 $(LIBS)

app_memory_barrier_asm_v2: app_memory_barrier_asm_v2.o
	g++ $^ -o app_memory_barrier_asm_v2 $(LIBS)

app_memory_barrier_asm_v3: app_memory_barrier_asm_v3.o
	g++ $^ -o app_memory_barrier_asm_v3 $(LIBS)

app_memory_barrier_asm_v4: app_memory_barrier_asm_v4.o
	g++ $^ -o app_memory_barrier_asm_v4 $(LIBS)

app_memory_barrier_asm_v5: app_memory_barrier_asm_v5.o
	g++ $^ -o app_memory_barrier_asm_v5 $(LIBS)


app_atomic: app_atomic.o
	g++ $^ -o app_atomic $(LIBS)

.PHONY: clean
clean:
	rm -rf $(TARGETS) *.o